<extend name="public:template" />
<block name="title">敏感词管理</block>
<block name="before_style">
    <link rel="stylesheet" href="__STATIC__/bootstrap/css/bootstrap.min.css">
</block>

<block name="style">
    <style>
        .del_words{ padding: 5px 8px; font-size: 12px; font-weight: normal; margin-right: 5px; cursor: pointer;}
    </style>
</block>
<block name="content">
    <div class="wrap-page">
        <div id="pageConfigSite" class="page-content">
            <include file="public:subtabs"/>
            <form class="form default-style" role="form" id="setting_site_form" action="{:u('backend/settings/unabledwords')}" method="post">
                <div id="boxConfigSite" class="box">
                    <div class="box-content">

                        <dl class="clearfix">
                            <dt><label>敏感词：</label></dt>
                            <dd>

                                <div class="item-field clearfix">
                                    <input  type="text" class="textfield" name="words" id="words"
                                            placeholder="请输入敏感词" autocomplete="off"/>
                                    <button type="button" class="save button button-blue">保存</button>
                                </div>
                            </dd>
                        </dl>

                        <dl class="clearfix">
                            <div class="panel panel-info" style="width: 97%; margin-top: 20px; margin-left: 30px;">

                                <div class="panel-body">
                                    <notempty name="list">
                                        <volist name="list" id="vo">
                                            <span class="del_words label {$class_list[rand(0,5)]}" data-id="{$vo.id}" title="点击删除">{$vo.words}</span>
                                        </volist>
                                    </notempty>
                                </div>
                            </div>
                        </dl>

                    </div>
                </div>

            </form>
        </div>
    </div>
</block>

<block name="script">
    <script>
        $(document).ready(function(){

            $('.save').click(function(){
                //数据验证
                $.ajax({
                    type: "POST",
                    url: $('.form').attr('action'),
                    data: $('.form').serialize(),
                    dataType: "json",
                    success:function(data){
                        if(data.status)
                        {
                            layer.msg(data.msg,{icon: 1,time:2000, shade: [0.1, '#ccc']},function(){
                                window.location.reload();
                            });
                        } else {
                            layer.msg(data.msg,{icon: 2,time:2000, shade: [0.1, '#ccc']})
                        }
                    }
                });
                return false;
            });

            $('.del_words').on('click',function(){
                var id  = $(this).attr('data-id');
                var url = "{:U('backend/settings/del_words')}";
                layer.confirm('确定删除？', function(){
                    $.post(url,{id:id},function(res){
                        if(res.status)
                        {
                            layer.msg(res.msg,{icon:1, time:2000}, function(){
                                window.location.reload();
                            })
                        }
                    },'json')
                });
            })
        });
    </script>
</block>